<?

class Module
{
    public $_moduleID="";

    public static function exists($moduleID)
    {
        if(!isset($GLOBALS["CONF"]["admin"]["modules"][$moduleID])) return false;
        return true;
    }

    public function __construct($moduleID)
    {
        $this->_moduleID = $moduleID;
    }

    public function __get($prop)
    {
            if(isset($GLOBALS["CONF"]["admin"]["modules"][$this->_moduleID] [$prop])) return $GLOBALS["CONF"]["admin"]["modules"][$this->_moduleID] [$prop];
            else return "";
    }

    public function __set($prop, $value) {} // read only ;)
    
    public function getCurrentAccountID($moduleID = 'accounts', $moduleClass='accountsAccount')
    {
        global $dbLink, $user;
        if(array_key_exists($moduleID, getAllModules()))
        {
            $account = new $moduleClass();
            if($user->sessionManager->exists($account->_dbIndex))
            {
                $account->setDBLink($dbLink);
                if($account->get($user->sessionManager->get($account->_dbIndex))) $accountID=$account->getID();
            }
        }
        else  $accountID=0;
        
        return (int)$accountID;

    }
}

?>
